
mod codec;

#[inline]
pub fn get_mut<T>(value: &T) -> &mut T {
    unsafe {
        let const_ptr = value as *const T;
        let mut_ptr = const_ptr as *mut T;
        &mut (*mut_ptr)
    }
}

#[inline]
pub fn new_bytes(len: usize) -> Box<[u8]> {
    let mut buf = Vec::with_capacity(len);
    unsafe {
        buf.set_len(len);
        buf.into_boxed_slice()
    }
}

pub fn xor_sum(buf: &[u8]) -> u8 {
    let mut s = 0;
    for v in buf {
        s = s ^ *v;
    }
    s
}